﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>特定考试成绩上传</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-body layui-form">
            <div class="layui-form-item">
                <label for="EQSubject" class="layui-form-label">
                    <span class="we-red">*</span>考试成绩数据
                </label>
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" id="upload">
                        <i class="layui-icon">&#xe67c;</i>选择文件
                    </button>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="EQSubject" class="layui-form-label">
                    <span class="we-red">&nbsp;</span>
                </label>
                <button class="layui-btn" id="btnUpload">导入数据</button>
            </div>
        <!--</form>-->
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form', 'upload', 'jquery', 'layer'], function () {
            var form = layui.form,
                upload = layui.upload,
                $ = layui.jquery,
                layer = layui.layer;
            $.support.cors = true;
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            var uploadInst = upload.render({
                elem: '#upload',
                url: ApiUrl + "SpecialExamScore/Upload",
                //data: { EQSubject: $("#EQSubject").val() },
                //data: {
                //    EQSubject: function () {
                //        return $('#EQSubject').val();
                //    }
                //},
                accept: "file",
                acceptMime: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                exts: 'xls|xlsx',
                auto: false,
                bindAction: "#btnUpload",//需要做判断，如果这里直接绑定，无法做相应判断
                before: function (obj) {
                    layer.load(); //上传loading
                },
                done: function (data) {
                    layer.closeAll('loading');
                    //上传完毕回调
                    if (data.StatusCode == 200 && data.Count != 0) {
                        layer.alert(data.Info, { icon: 6 }, function (index) {
                            parent.layer.closeAll();
                        })
                    }
                    else if (data.StatusCode == 403) {
                        top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                            top.location.href = "http://" + top.location.host + "/login.html";
                        })
                    }
                    else {
                        layer.msg(data.Info);
                    }
                },
                error: function () {
                    layer.closeAll('loading');
                }
            });

        });
    </script>
</body>
</html>